package WaitNotify.demo2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2022-12-25
 * Time: 14:04
 */
public class DownLoader {

    public static List<String> downLoad() throws IOException {
        //下载百度首页
        HttpURLConnection connection = (HttpURLConnection) new URL("https://cn.bing.com/").openConnection();
        List<String> lines = new ArrayList<>();
        try(BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
            String line;
            while((line= bufferedReader.readLine()) != null) {
                lines.add(line);
            }
        }
        return lines;
    }

}
